package com.many_to_many;

import com.bean.Student;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface StudentMapper {
    //查询全部
    @Select("select distinct s.id,s.name,s.age from student s,stu_cr sc where sc.sid=s.id")
    @Results({
            @Result(column = "id",property = "id"),
            @Result(column = "name",property = "name"),
            @Result(column = "age",property = "age"),
            @Result(
                property = "courses",
                javaType = List.class,
                column = "id",
                many = @Many(select = "com.many_to_many.CourseMapper.selectBySid")
            )
    })
    public abstract List<Student>selectALL();
}
